package leetcode.weekly.week296;

import java.util.Arrays;

//Solution2Test
public class Solution2 {

	// Solution2Test
	public int partitionArray(int[] nums, int k) {
		Arrays.sort(nums);
		int ans = 0;
		int l = 0;
		int r = 0;
		int len = nums.length;
		// 1,2,3,5,6
		while (r < len) {
			while (r < len && nums[r] - nums[l] <= k) {
				r++;
			}
			ans++;
			l = r;
		}
		return ans;
	}

}
